<?php

namespace App\Models\Product;

use Illuminate\Database\Eloquent\Model;

use DateTimeInterface;

use App\Models\Config as ConfigModel;

class Type extends Model
{
    protected $table = 'product_type';

    protected $appends = [
        'thumb_text',
    ];

    public function getThumbTextAttribute()
    {
        $url = ConfigModel::where('name', 'shopurl')->value('value');

        // 上面查询的fastAdmin地址可能是线上的，如果请在该项目.env环境配置文件的本地开发地址
        $url = env('SITE_URL', $url);

        $thumb = !empty($this->attributes['thumb']) ? $url . $this->attributes['thumb'] : $url . '/assets/images/icon_1.png';

        return $thumb;
    }
}
